﻿using Skauler.BusinessModel;
using Skauler.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.DirectoryServices;
using Skauler.ViewModels;

namespace Skauler
{
    public class MainWindowViewModel : SkaulerViewModelBase
    {
      //  private School _schoolData;
        private Employee _employee;
        private SkaulerViewModelBase _currentPage;
      //  private SkaulerViewModelBase _EmployeePage;
        private List<MenuItem> _mainMenuGroup;

        public List<MenuItem> MainMenuGroup
        {
            get
            {
                return _mainMenuGroup;
            }
        }
        //public SkaulerViewModelBase EmployeePage
        //{
        //    get
        //    {
        //        return _EmployeePage;
        //    }
        //    set
        //    {
        //        _EmployeePage = value;
        //    }
        //}
        public SkaulerViewModelBase CurrentPage
        {
            get
            {
                return _currentPage;
            }
            set
            {
                _currentPage = value;
            }
        }

        public MainWindowViewModel(Employee employeeData)
            : base(employeeData)
        {
             _employee = employeeData;
       //     _schoolData = schoolData;
            //Check for License and Activation
            InitializeMenu();
            InitializeStudentPage();
        }

        private void InitializeMenu()
        {
            _mainMenuGroup = new List<MenuItem>();

            //Menu Student
            MenuItem studentItem = new MenuItem();
            studentItem.ItemName = "student";
            studentItem.SubItem = new List<MenuItem>();
            studentItem.SubItem.Add(new MenuItem { ItemName = "ADMISSION" });
            studentItem.SubItem.Add(new MenuItem { ItemName = "CLASS" });
            //Menu Staff
            MenuItem staffItem = new MenuItem();
            staffItem.ItemName = "staff";
            staffItem.SubItem = new List<MenuItem>();
            staffItem.SubItem.Add(new MenuItem { ItemName = "ALL STAFF" });

            MenuItem reportItem = new MenuItem();
            reportItem.ItemName = "report";
            _mainMenuGroup.Add(studentItem);
            _mainMenuGroup.Add(staffItem);
            _mainMenuGroup.Add(reportItem);


        }
        private void InitializeStudentPage()
        {
            _currentPage = new AddEmployeeDetailsViewModel(_employee);
       //       _EmployeePage = new AddEmployeeDetailsViewModel(_employee);
        }
        /// <summary>
        /// Returns the SID for Machine Name.
        /// This is Unique ID for each Windows Install.
        /// </summary>
        /// <returns></returns>
        private string GetSystemUniqueId()
        {
            return new SecurityIdentifier((byte[])new DirectoryEntry(string.Format("WinNT://{0},Computer", Environment.MachineName)).Children.Cast<DirectoryEntry>().First().InvokeGet("objectSID"), 0).AccountDomainSid.Value;
        }
        public override string Title
        {
            get
            {
                return "SKAULER";
            }
        }
        //public School SchoolDetails
        //{
        //    get
        //    {
        //        return _schoolData;
        //    }
        //}
        public Employee EmployeeDetails 
        {
            get 
            {
                return _employee;
            }
        }
    }
}
